package com.dykj.fireFighting.server.base.video.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dykj.fireFighting.api.base.video.entity.PartitionsVideo;
import com.dykj.fireFighting.api.base.video.service.IPartitionsVideoService;
import com.dykj.fireFighting.common.core.service.impl.BaseServiceImpl;
import com.dykj.fireFighting.common.core.utils.UUIDUtils;
import com.dykj.fireFighting.server.base.video.mapper.PartitionsVideoMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.transaction.annotation.Transactional;



import java.util.List;
import java.util.Map;

/**
 * 摄像头中间表
 *
 * @Author JacksonTu
 * @Date  2021-07-26 13:37:56
 */
@Slf4j
@DubboService
@Transactional(rollbackFor = Exception.class)
public class PartitionsVideoServiceImpl extends BaseServiceImpl<PartitionsVideoMapper, PartitionsVideo> implements IPartitionsVideoService {


    @Override
    public int savePosition(PartitionsVideo video) {
        LambdaQueryWrapper<PartitionsVideo> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(PartitionsVideo::getVideoId,video.getVideoId());
        List<PartitionsVideo> list= this.baseMapper.selectList(wrapper);
        if(list.size()>0)
        {
            video.setId(list.get(0).getId());
            this.baseMapper.updateById(video);
        }else{
            video.setId(UUIDUtils.get32UUID());
            this.baseMapper.insert(video);
        }


        return 0;
    }
}
